package com.javaee6.votinator;
import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.OneToMany;
import javax.persistence.NamedQuery;

import com.mkulla.jee6.projectmanager.model.Override;


@Entity 
@NamedQueries({
	@NamedQuery(name = User.FIND_ALL, query = "select u from User u order by u.id"),
	@NamedQuery(name = User.FIND_BY_NAME, query = "select u from User u where u.fName =:fName"),
//	@NamedQuery(name = User.LOGIN, query ="select u from User where u.email =:email && where u.pw =:pw"),
	//@NamedQuery(name = User. FIND_BY_SCHOOL, query = "select u from User u where u.school =: school")
	})
public class User implements Serializable {

    public static final String FIND_ALL = "User.findAll";
    public static final String FIND_BY_NAME = "User.findByName";
    public static final String FIND_BY_SCHOOL = "User.findBySchool";
    public static final String LOGIN = "User.login";
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	private String fName;
	private String lName;
	private String email;
	private String pw;
	private String birthDate;
	private String school;
	private String university;
	


//	@ManyToOne(optional=false)

	public User(String firstName, String lastName, String School,
			String universisty, String birthDate) {
		this.fName = firstName;
		this.lName = lastName;
		this.school = School;
		this.university = universisty;
	}
	public User() {
		
	}
	
    @Override
    public int hashCode() {
        int hash = 7;
        hash = 53 * hash + (this.id != null ? this.id.hashCode() : 0);
        hash = 53 * hash + (this.fName != null ? this.fName.hashCode() : 0);
        hash = 53 * hash + (this.lName != null ? this.lName.hashCode() : 0);
        hash = 53 * hash + (this.email != null ? this.email.hashCode() : 0);
        return hash;
    }

	// --- Getters && Setters ---
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getFirstName() {
		return fName;
	}

	public void setFirstName(String firstName) {
		this.fName = firstName;
	}

	public String getLastName() {
		return lName;
	}

	public void setLastName(String lastName) {
		this.lName = lastName;
	}

	public String getSchool() {
		return school;
	}

	public void setSchool(String school) {
		this.school = school;
	}

	public String getUniversity() {
		return university;
	}

	public void setUniversity(String university) {
		this.university = university;
	}

	public String getBirthDate() {
		return birthDate;
	}

	public void setBirthDate(String birthDate) {
		this.birthDate = birthDate;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getPw() {
		return pw;
	}
	public void setPw(String pw) {
		this.pw = pw;
	}
	
	
	

}
